package com.beordie.version_2.aop.interceptor;

import com.beordie.version_2.aop.aspect.BODAbstractAspectJAdvice;
import com.beordie.version_2.aop.config.BODJoinPoint;

import java.lang.reflect.Method;

/**
 * @Description
 * @Date 2022/2/22 15:13
 * @Created 30500
 */
public class BODAfterReturningAdviceInterceptor extends BODAbstractAspectJAdvice implements BODMethodInterceptor{
    /**
     * 参数对象
     */
    private BODJoinPoint joinPoint;

    public BODAfterReturningAdviceInterceptor(Object newInstance, Method method) {
        super(newInstance, method);
    }

    @Override
    public Object invoke(BODMethodInvocation invocation) throws Throwable {
        this.joinPoint = invocation;
        Object result = invocation.procced();
        this.afterReturning(result, invocation.getMethod(), invocation.getArgument(), invocation.getThis());
        return null;
    }

    private void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable{
        this.invokeAdviceMethod(this.joinPoint, returnValue,null);
    }
}
